'use strict';

const BaseService = require('./base');

class LogisticsTrackService extends BaseService {
  constructor(ctx) {
    super(ctx, 'LogisticsTrack');
  }
  
  // 重写create方法，支持事务
  async create(data, transaction = null) {
    const options = {};
    if (transaction) options.transaction = transaction;
    
    return this.ctx.model.LogisticsTrack.create(data, options);
  }
  
  // 根据订单ID获取物流轨迹
  async getTracksByOrderId(orderId) {
    return this.ctx.model.LogisticsTrack.findAll({
      where: { order_id: orderId },
      order: [['create_time', 'DESC']]
    });
  }
}

module.exports = LogisticsTrackService;
